<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>东单办公系统-部门修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="media/layui/css/layui.css" media="all">
    <script type="text/javascript" src="media/js/jquery.min.js"></script>
    <script src="media/layui/layui.js"></script>
    <script type="text/javascript">
        $(function () {
            var json = getData();
            var obj = JSON.parse(decodeURI(json));
            showData(obj);
        })

        function getData() {
            var url = window.location.search;
            index = url.indexOf("?");
            if (index > -1) {
                var str = url.substr(index + 1);
                if (str.indexOf('=')) {
                    return str.split('=')[1];
                }
            }
            return null;
        }

        function showData(obj) {
            $("#f1").val(obj.id);
            $("#f2").val(obj.name);
            $("#f3").val(obj.createtime);
            $("#f4").val(obj.week);
            $("#f5").val(obj.location);

        }
    </script>
</head>
<body>

<div class="layui-container" style="margin-top: 5px">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">班级序号</label>
            <div class="layui-input-block">
                <input type="text" name="id" readonly="readonly" autocomplete="off"
                       class="layui-input" id="f1">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">班级名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="require"
                       autocomplete="off" class="layui-input" id="f2">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开班日期</label>
            <div class="layui-input-block">
                <input type="text" name="createtime" readonly="readonly" id="f3"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">周期</label>
            <div class="layui-input-block">
                <input type="number" name="week" lay-verify="require"
                       autocomplete="off" class="layui-input" id="f4">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">班级位置</label>
            <div class="layui-input-block">
                <input type="text" name="location" lay-verify="require"
                       autocomplete="off" class="layui-input" id="f5">
            </div>
        </div>

        <div class="layui-form-item">
            <button class="layui-btn" style="margin-left: 100px" type="button" onclick="clickit()">修改</button>
        </div>
    </form>
</div>

<script src="media/layui/layui.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    function clickit() {
        $.ajax({
            type: "post",
            data: $('form').serialize(),
            url: "grade/updateGrade.do",
            success: function (res) {
                console.log(res)
                if (res.code == 0) {
                    //console.log("修改成功")
                    alert("修改成功")
                    window.location.href = "gradelist.html"
                } else {
                    alert(1)
                }
            },
            error: function () {
                console.log("error")
            }
        })
        return false;
    }
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'laydate'], function () {
        var form = layui.form, layer = layui.layer, laydate = layui.laydate;
    });
</script>
</body>
</html>